var webpack = require('webpack')

var plugins = [
  new webpack.DefinePlugin({
    'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
  })
]

if (process.env.COMPRESS) {
  plugins.push(
    new webpack.optimize.UglifyJsPlugin({
      compressor: {
        warnings: false
      }
    })
  )
}

module.exports = {
  entry: './lib/index.js'
, output: {
    filename: 'react-a11y.js'
  , path: './dist'
  , library: 'A11y'
  , libraryTarget: 'var'
  }
, externals: process.env.NODE_DIST ? {} : {
    react: 'React'
  }
, node: {
    buffer: false
  }
, plugins: plugins
, module: {
    loaders: [{
      test: /\.js$/
    , exclude: /node_modules/
    , loader: 'babel-loader'
    }]
  }
}
